package com.adinnet.api.sentence.controller;


import com.adinnet.api.sentence.service.SentenceService;
import com.adinnet.core.JsonResult;
import com.adinnet.core.exception.BizException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 跟随训练表（短句） 前端控制器
 * </p>
 *
 * @author zYshuai
 * @since 2020-12-02
 */
@RestController
@RequestMapping("/api/sentence")
public class SentenceController {

    @Autowired
    private SentenceService sentenceService;


    /**
     * 根据词汇id查询儿童单个短句信息
     * @param childId 儿童id
     * @param sentenceId  短句id
     * @return
     */
    @GetMapping("details")
    public JsonResult sentenceDetails(Integer childId,Integer sentenceId) {
        try {
            if (null == childId) {
                return JsonResult.error("儿童id不能为空");
            }
            if (null == sentenceId) {
                return JsonResult.error("短句id不能为空");
            }
            return sentenceService.sentenceDetails(childId,sentenceId);

        } catch (BizException e) {
            return JsonResult.error(e.getMessage());
        } catch (Exception e) {
            return JsonResult.error("查询词汇详情失败!");
        }
    }

}
